#pragma once
#ifndef SYPX_SPRITEINSTANCE
#define SYPX_SPRITEINSTANCE

#include "MeshInstance.h"
#include "Sprite.h"

namespace SypX
{

	class Sprite;
	///A SpriteInstance is an instance of a Sprite. While a MeshInstance can use a 
	///Sprite by calling useMesh/useTexture(using the Sprite as a mesh and it's contained texture) explicitly,
	///SpriteInstance automatically handles these operations via useSprite(). More importantly, SpriteInstance
	///contains important Sprite specific state information like current orientation(or angle), frame number and action.	
	class SYPXAPI SpriteInstance : public MeshInstance
	{
	public:
		///Default SpriteInstance Constructor
		SpriteInstance(void);
		///Decontructor
		~SpriteInstance(void);
		///Sets this SpriteInstance to use this Sprite
		void useSprite(Sprite* s);
		///Returns the Sprite currently in use
		Sprite* getSprite();
		///Sets active action by index
		void setActiveAction(UByte index);
		///Sets active Action by actionname
		void setActiveAction(const String& actionName);
		///Set Active frame
		void setActiveFrame(UByte frame);
		///Set current angle (0-12)
		void setActiveAngle(UByte angle);
		///Returns the currently active Action
		UByte getActiveAction();
		///Returns the currently active Frame
		UByte getActiveFrame();
		///Returns the currently active Angle
		UByte getActiveAngle();
		///Updates to next Frame
		void nextFrame();
		///Do any pre-rendering updates (Changes to mesh/sprite state) before the draw call
		virtual void update();
		///Updates SpriteInstance by elapsedTime (Untested)
		void update(float elapsed);
	private:
		float currTime;
		UByte activeAction;
		UByte activeFrame;
		UByte activeAngle;
		Sprite* sprite;
	};

}
#endif